<?php 
set_time_limit(0);
include ("../../nncms_manager_inc.php");
include LOGIC_DIR.'nl_config.php';
include LOGIC_DIR.'nl_common.func.php';

$dc = nl_get_dc(array("db_policy" => NL_DB_WRITE, "cache_policy" => NP_KV_CACHE_TYPE_MEMCACHE));
$dc->open();
$db = $dc->db();

$sql = 'select count(1) as num from nns_assists_item';
$count = nl_query_by_db($sql, $db);
$count = $count[0]['num'];

echo '<pre>';
for ($i=0; $i<$count; $i++){
	$offset = $i==0?'0':$i;
	$sql = 'select * from nns_assists_item order by nns_order limit '.$offset.',1';
	$assets_item = nl_query_by_db($sql, $db);
	
	if($assets_item[0]['nns_video_type']==0){
		$vod = get_vod_info($db, $assets_item[0]['nns_video_id']);
	}else{
		$vod = get_live_info($db, $assets_item[0]['nns_video_id']);
	}
	$nns_summary = $vod[0]['nns_summary'];
	
	$sql = 'update nns_assists_item set nns_summary=\''.$nns_summary.'\' where nns_id=\''.$assets_item[0]['nns_id'].'\'';
	nl_execute_by_db($sql, $db);
	
	$info = $assets_item[0]['nns_id'].'___'.$assets_item[0]['nns_video_name'].'___'.$assets_item[0]['nns_video_type'];
	echo $info.'<br>';
}

function get_vod_info($db, $id){
	$sql = 'select nns_summary from nns_vod where nns_id=\''.$id.'\'';
	
	return nl_query_by_db($sql, $db);
}

function get_live_info($db, $id){
	$sql = 'select nns_summary from nns_live where nns_id=\''.$id.'\'';
	
	return nl_query_by_db($sql, $db);
}
